package hoowin.app.cadc.action;

import hoowin.app.cadc.service.BaomingService;
import hoowin.basic.util.Encoder;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class BaomingAction extends ActionSupport {
	private String biao;
	private int size;
	private InputStream inputStream;
	public void setBiao(String biao) {
		this.biao = biao;
	}
	public String getBiao() {
		return biao;
	}
	public void setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
	}
	public InputStream getInputStream() {
		return inputStream;
	}
	public String execute(){
		try {
			byte[] biaoByte = Encoder.decryptBASE64(biao);
			byte[] pdfByte = BaomingService.toPdf(biaoByte);
			setSize(pdfByte.length);
			setInputStream(new ByteArrayInputStream(pdfByte));
		} catch (IOException e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
	public void setSize(int size) {
		this.size = size;
	}
	public int getSize() {
		return size;
	}
}
